package com.softer.chengxin.param.dao.provider;

import com.softer.chengxin.param.entity.ScoreType;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * @author Gong Zhiyang
 * @date 2019/12/14
 */

public class ScoreTypeDaoProvider {
    /**
     * 查询评分类型列表
     *
     * @param map 查询实体
     * @return 查询语句
     */
    public String getScoreTypeList(Map<String, ScoreType> map) {
        StringBuilder sql = new StringBuilder(6);
        ScoreType scoreType = map.get("s");
        sql.append("SELECT id,score_name as scoreName,max_score as maxScore,type,state FROM score_type");
        sql.append(" where type=#{s.type}");
        if (StringUtils.isNotBlank(scoreType.getScoreName())){
            sql.append(" and instr(score_name,#{s.scoreName})>0");
        }
        return sql.toString();
    }
}
